- Working in different contexts: RStudio Projects
- Dynamic document generation: RMarkdown
- Version control: Git + GitHub
- Package management: renv
- Containerization: Docker
- Where should I start?
- Start collaborating
13/01/2021
here-package (Müller, 2020) to define relative paths within the project: read.csv(here::here("data", "file_I_want.csv"))knitr (Xie, 2015, 2020) and tinytex (Xie, 2015, 2020; for pdfs)install.packages("rmarkdown") (Allaire et al., 2017)install.packages("knitr") (Xie 2015, 2020)install.packages("rmarkdown") (Allaire et al., 2017)install.packages("knitr") (Xie 2015, 2020)install.packages("rmarkdown")
knitr-package (Xie, 2014, 2015, 2020) to customize chunks and knitting process
{r cache=TRUE,message=FALSE,warning=FALSE,results="hide", error = TRUE}opts_chunk$set()-functionTinyTeX (Xie, 2010) is a light-weight, cross-platform distribution (install.packages("tinytex"); tinytex::install_tinytex()))#/*
rmarkdown::render(input = rstudioapi::getSourceEditorContext()$path,
output_format = rmarkdown::github_document()),
knit_root_dir = getwd()) #*/
update.packages(ask = FALSE, checkBuilt = TRUE))git --version. If “git: command not found”:xcode-select --install. Restart R.git config --global user.name 'your name'git config --global user.email 'email associated with your GitHub account'git config --global --list (Check whether everything worked)git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git (your link) in the shell (Terminal in RStudio or on Mac, Git Bash on Windows)
cd YOUR-REPOSITORY), list its files (ls), display README (head README.md), get info on its connection to GitHub (git remote show origin)echo "This is the first change to my repo" >> README.md git status
add), commit (commit - m "YOUR-COMMIT-MESSAGE), and push change. You may be asked for your username and password.git add -A git commit -m "A commit from my local computer" git push
- (Clean up: Delete your local repo (`cd`, and then `rm -rf YOUR-REPO-NAME/`))
install.packages() to install packages in this local libraryrenv.lock fileinstall.packages(renv)renv::init()renv::snapshot()renv::restore()renv::init()renv.lock fileinstall.packages("cowsay")
cowsay::say("Hello world", "cow")
renv::snapshot()Restoring someone else’s package versions:
projectname.Rproj file)renv::restore() to install the package versions from the renv.lock fileN:/).Rmd files) on this virtual systemDockerfile that can be shared via GitHubdocker run -d -e PASSWORD=1234 -p 8787:8787 -v /path/to/your/project:/home/rstudio/ rocker/rstudio
Dockerfile in your project directy, specyfing additional steps to execute when building the container, e.g., install.packages("renv"); renv::restore()Dockerfile for you if you don’t have your own one